<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;


class CreateHscoinExchangeTable extends Migration
{
    public function up()
    {
        Schema::create('hscoin_exchange', function (Blueprint $table) {
            $table->unsignedInteger('id')->autoIncrement()->comment('奖池id');
            $table->unsignedBigInteger('uid')->notNull()->default(0);
            $table->tinyInteger('category')->unsigned()->notNull()->default(0)->comment('1 现金 2积分');
            $table->decimal('hscoin_amount', 12, 2)->unsigned()->notNull()->default(0.00)->comment('奖池统计');
            $table->decimal('price', 12, 2)->unsigned()->notNull()->default(0.00)->comment('价格');
            $table->decimal('result_amount', 12, 2)->unsigned()->notNull()->default(0.00)->comment('余额');
            $table->decimal('fee_rate', 12, 2)->unsigned()->notNull()->default(0.00)->comment('费率');
            $table->decimal('fee', 12, 2)->unsigned()->notNull()->default(0.00)->comment('费用');
            $table->tinyInteger('status')->notNull()->default(1)->comment('0 = 带确定 1 = 有效 -1 = 无效，初始有效，要更改为无效，用新记录做对冲');
            $table->unsignedInteger('add_time')->notNull()->default(0);
            $table->index('add_time');
        });
    }

    public function down()
    {
        Schema::dropIfExists('hscoin_exchange');
    }
}